package cn.tradewin.pmp.services.impl;

import java.util.ArrayList;
import java.util.List;

import org.slf4j.Logger;

import cn.tradewin.common.model.SelectOption;
import cn.tradewin.common.util.XmemcachedKeys;
import cn.tradewin.pmp.services.MasterService;

import com.whalin.MemCached.MemCachedClient;

public class MasterServiceImpl implements MasterService {
	
	private Logger log;
	
	private MemCachedClient memcachedClient;
	
	public MasterServiceImpl(final Logger log, MemCachedClient memcachedClient) {
		this.log = log;
		this.memcachedClient = memcachedClient;
	}

	@Override
	public List<SelectOption> getSupportCountry() {
		List<SelectOption> countries = null;
			countries = (List<SelectOption>)memcachedClient.get(XmemcachedKeys.CACHED_SUPPORTED_COUNTRY);
			if (countries == null) {
				countries = new ArrayList<SelectOption>();
				countries.add(new SelectOption("China", "zh"));
			}
			memcachedClient.set(XmemcachedKeys.CACHED_SUPPORTED_COUNTRY, countries);		
		return countries;
	}
}
